Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  The language {0n1n2n| 1 ≤ n ≤ 106... Start Learning for Free
The language {0n 1n 2n | 1 ≤ n ≤ 106} is 
  • a)
    regular
  • b)
    context-free but not regular.
  • c)
    context-free but its complement is not context-free.
  • d)
    not context-free
Correct answer is option 'A'. Can you explain this answer?
Verified Answer
The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-fr...
The value of ‘n’ is finite. So, only finite number of strings can be part of given language. Therefore, we can construct a finite state automata for this language. 
 
Thus, option (A) is correct. 
 
Please comment below if you find anything wrong in the above post.
View all questions of this test
Most Upvoted Answer
The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-fr...
Explanation:

The language {0n1n2n| 1 ≤ n ≤ 106} is a language of strings containing equal numbers of 0s, 1s, and 2s such that the number of 1s is between 1 and 106.

To determine whether this language is regular, context-free, or not context-free, we can use the pumping lemma for each of these classes of languages.

1. Regular:

Let L be a regular language. According to the pumping lemma for regular languages, there exists a constant p such that any string s in L of length at least p can be divided into three parts, s = xyz, such that:

1. |xy| ≤ p
2. |y| > 0
3. xyiz ∈ L for all i ≥ 0

We can apply this lemma to the language {0n1n2n| 1 ≤ n ≤ 106} by assuming that it is regular and deriving a contradiction.

Let p be the constant given by the pumping lemma for regular languages. Consider the string s = 0p1p2p ∈ L, which has length 3p. By the pumping lemma, s can be divided into three parts, s = xyz, such that |xy| ≤ p, |y| > 0, and xyiz ∈ L for all i ≥ 0.

Since |xy| ≤ p, the string y consists entirely of 0s. Therefore, if we pump y, we obtain a string that contains more 0s than 1s, which is not in L. This contradicts the pumping lemma, so the language {0n1n2n| 1 ≤ n ≤ 106} is not regular.

2. Context-free:

Let G = (V, Σ, R, S) be a context-free grammar for a language L. According to the pumping lemma for context-free languages, there exists a constant p such that any string s in L of length at least p can be divided into five parts, s = uvxyz, such that:

1. |vxy| ≤ p
2. |vy| > 0
3. uvixyiz ∈ L for all i ≥ 0

We can apply this lemma to the language {0n1n2n| 1 ≤ n ≤ 106} by assuming that it is context-free and deriving a contradiction.

Suppose there exists a context-free grammar G = (V, Σ, R, S) for the language {0n1n2n| 1 ≤ n ≤ 106}. We can construct a string s ∈ L that has length greater than p, where p is the constant given by the pumping lemma for context-free languages.

Let s = 0p1p2p ∈ L, which has length 3p. By the pumping lemma, s can be divided into five parts, s = uvxyz, such that |vxy| ≤ p, |vy| > 0, and uvixyiz ∈ L for all i ≥ 0.

Since |vxy| ≤ p, the substring vxy must be contained entirely within the first p symbols of s, which consists only of 0s. Therefore, we can write vxy = 0k for some integer k > 0.

If we pump vxy, we obtain a string that contains
Explore Courses for Computer Science Engineering (CSE) exam
Question Description
The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer?.
Solutions for The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer?, a detailed solution for The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? has been provided alongside types of The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice The language {0n1n2n| 1 ≤ n ≤ 106} isa)regularb)context-free but not regular.c)context-free but its complement is not context-free.d)not context-freeCorrect answer is option 'A'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam
Signup to solve all Doubts
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev